package com.github.fork.service.impl;

import com.github.fork.entity.Country;
import com.github.fork.entity.University;
import com.github.fork.service.CountryService;
import com.github.fork.service.DemoService;
import com.github.fork.service.UniversityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;

/**
 * @author Jerry Liu
 * @since 2017/3/31
 */
@Service
public class DemoServiceImpl implements DemoService {

    @Autowired
    private UniversityService universityService;

    @Autowired
    private CountryService countryService;

    @Transactional(transactionManager = "transactionManager")
    @Override
    public void demo() {

        University university = new University();
        university.setCode("90000");
        university.setName("麦子学院");
        university.setEnglish("maizijinfu");
        university.setNation("CHN");
        university.setLocation("上海");
        university.setDistrict("上海");
        university.setGmtCreated(new Date());

        Country country = new Country();
        country.setFullName("德意志联邦共和国");
        country.setShortName("德国");
        country.setCode("GER");
        country.setAbbr("Germany");
        country.setEnglish("The Federal Republic of Germany");
        country.setCapital("柏林");
        country.setGmtCreated(new Date());
        country.setGmtModified(new Date());

        universityService.add(university);

        countryService.add(country);


        /*String x = null;
        if (x.equals("rt")){
            System.out.println("======会回滚吗？======");
        }*/

    }
}
